﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace DARE
{
    /// <summary>
    /// 
    /// </summary>
    public class CLModel : ALoadHelper
    {
        #region Fields

        protected Model m_model;

        #endregion

        #region Property

        /// <summary>
        /// 
        /// </summary>
        [ContentSerializerIgnore]
        public Model Data
        {
            get { return this.m_model; }
            protected set
            {
                if (this.m_model != value)
                    this.m_model = value;
            }
        }

        #endregion

        #region CTOR

        /// <summary>
        /// 
        /// </summary>
        public CLModel()
        {

        }

        /// <summary>
        /// 
        /// </summary>
        public CLModel(string _path)
            : base(_path)
        {
        }

        public CLModel(Model mod)
        {
            this.m_model = mod;
        }

        #endregion

        #region Method

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lastPath"></param>
        protected override void ReLoad(string lastPath)
        {
            this.Data = CResourceMgr.Load<Model>(base.Path);
            if (!string.IsNullOrEmpty(lastPath))
                CResourceMgr.UnLoad(lastPath);
            base.ReLoad(lastPath);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public static implicit operator Model(CLModel _model)
        {
            return _model.Data;
        }
        #endregion
    }
}
